<?php
class Jstodb_ctl extends Ctl{
    function __construct(){
    }
    function main(array $getVars) {
        $this::sessver();
        $type=$_POST['_dboper'];
        $dbtable=$_POST['_dbtable'];
        if($type=="add"){
            $array=array();
            $array2=array();
            foreach ($_POST as $k=>$v){
                if($k!="_dboper"&&$k!="_dbtable"){
                    if($k=="_dbarray2"){
                        $tem=explode('_',$v);
                        for ($i=0;$i<count($tem);$i++){
                            $array2[$tem[$i]]=$array[$tem[$i]];
                        }
                    }else{
                        $array[$k]=$v;
                    }
                }
            }
            echo xdb::getInstance()->indb($dbtable, $array, $array2);
        }elseif($type=="del"){
            $array=array();
            $id=$_POST['_dbarray2'];
            $array['id']=$id;
            echo xdb::getInstance()->deldb($_POST['_dbtable'], $array);
        }elseif($type=="upd"){
            $array=array();
            $array2=array();
            foreach ($_POST as $k=>$v){
                if($k!="_dboper"&&$k!="_dbtable"){
                    if($k=="_dbarray2"){
                        $array2['id']=$v;
                    }else{
                        $array[$k]=$v;
                    }
                }
            }
            echo xdb::getInstance()->updb($dbtable, $array, $array2);
        }
        
    }
}